/***********************************************************************************
Copy right:	    Coffee Tech.
Author:         jiaoyue
Date:           2022-03-23
Description:    http请求处理
***********************************************************************************/

#include "req_handle.h"
#include "log_console.h"


#define KB 1024
#define HTML_SIZE (64 * KB)

//普通的文本回复需要增加html头部
#define HTML_HEAD "Content-Type: text/html\r\n" \
				  "Connection: close\r\n"

/**
 * @brief 处理自定义请求，在这里添加进程通信
 * @param input
 * @return
 */
int parse_and_process(char *input)
{
    char val_buf[2048] = {0};
    strcpy(val_buf, input);

    char reply_buf[HTML_SIZE] = {0};
    sprintf(reply_buf, "%sContent-Length: %ld\r\n\r\n", HTML_HEAD, strlen(val_buf));
    strcat(reply_buf, val_buf);
    log_console("post json_str = %s", reply_buf);
    fputs(reply_buf, stdout);

    return 0;
}
